package com._520it.crm.service.impl;

import com._520it.crm.domain.Classroom;
import com._520it.crm.mapper.ClassroomMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.ClassroomQueryObject;
import com._520it.crm.service.IClassroomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ClassroomServiceImpl implements IClassroomService {
	@Autowired
	private ClassroomMapper classroomMapper;
	public void insert(Classroom record) {
		classroomMapper.insert(record);
	}

	public Classroom selectByPrimaryKey(Long id) {
		return classroomMapper.selectByPrimaryKey(id);
	}

	public List<Classroom> selectAll() {
		return classroomMapper.selectAll();
	}

	public void updateByPrimaryKey(Classroom record) {
		classroomMapper.updateByPrimaryKey(record);
	}

	@Override
	public PageResult queryPage(ClassroomQueryObject qo) {
		Integer count = classroomMapper.queryPageCount(qo);
		if(count <= 0){
			return new PageResult(0, Collections.EMPTY_LIST);
		}
		List<Classroom> result =  classroomMapper.queryPageData(qo);
		return new PageResult(count, result);
	}
}
